﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using CNotebook;

namespace NotebookS2
{
    public partial class M_CardDocument : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public M_CardDocument()
        {
            InitializeComponent();
        }

        public string ConnectionString { get; set; }
        public DataTable CardDocument { get; set; }

        private void btnAdd_Click(object sender, EventArgs e)
        {

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void M_DIVISION_Load(object sender, EventArgs e)
        {
            CardDocumentManager oManager = new CardDocumentManager();

            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();
            this.CardDocument = oManager.GetCardDocumentForGrid();
            oManager.Close();

            gridControl1.DataSource = this.CardDocument;
            gridControl1.Refresh();
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            CardDocumentManager oManager = new CardDocumentManager();

            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();

            oManager.UpdateCardDocument(this.CardDocument);

            this.CardDocument = oManager.GetCardDocumentForGrid();
            oManager.Close();

            gridControl1.DataSource = this.CardDocument;
            gridControl1.Refresh();

            MessageBox.Show("Document List is already updated!!!", "Document", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

    }
}
